# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This source file is part of the Cangjie project, licensed under Apache-2.0
# with Runtime Library Exception.
#
# See https://cangjie-lang.cn/pages/LICENSE for license information.


import os

operators = ['as', 'is']
dir = os.path.dirname(os.path.realpath(__file__))
path = dir + '/test_' + os.path.basename(dir) + '_{}.cj'
template = '''
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
 * This source file is part of the Cangjie project, licensed under Apache-2.0
 * with Runtime Library Exception.
 *
 * See https://cangjie-lang.cn/pages/LICENSE for license information.
 */

/*
  @Assertion:   4.17(2) The syntax of type test and type cast expressions is defined as:
                comparisonOrTypeExpression
                    : ...
                    | shiftingExpression ('is' type)?
                    | shiftingExpression ('as' userType)?
                    ;
  @Description: Check that operators `{op1}` and `{op2}` cannot go together
                ({} on the left, {} on the right).
  @Mode: compileonly
  @Negative: yes
  @Structure: single
  @CompileWarning: no
  @Comment: Auto-generated by gen.py
*/

main() {{
    {} {op1} {op2} {}
}}

'''

counter = 16

for op1 in operators:
  for op2 in operators:
    for i in range(2):
      for j in range(2):
        contents = template.format(*('type' if x else 'expression' for x in [i, j]),
                                   *('Int64' if x else '1' for x in [i, j]), op1=op1, op2=op2)
        with open(path.format(counter), 'w') as file:
          file.write(contents)
        counter += 1
